import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

MainView {
    id: root
    width: 800
    height: 391
    onPasswordFalse: {
        paraPanelDialog.title=qsTr("密码错误！")
        paraPanelDialog.open();
    }
    Dialog {
        anchors.centerIn: parent
        id: paraPanelDialog
        standardButtons: Dialog.Ok
        onAccepted: paraPanelDialog.close()
        z:100
    }
    GridLayout{ //root中放置一个行布局，布局中放置3个方块
        id: zeroCalibrationLayout
        anchors.centerIn: parent
        rowSpacing: 20
        columnSpacing: 20 //间距
        rows: 2//行数
        columns: 3 //列数
        Button
        {
            id:btnNormalSettings
            Layout.row: 0
            Layout.column: 0
            Layout.preferredWidth : 185
            Layout.preferredHeight: 85
            background: Rectangle{
                border.width: 0
                color: "#7584C2"
                    }

            text: qsTr("常规设置")
            font.pixelSize: 25
            palette.buttonText: "white"
            onClicked: {
                settingsLoader.visible=true;
                bottomBar.selected=4
//                myLoader.visible=false;
//                myLoader.visible=true
                myLoader.source="NormalSettings.qml"
            }
        }
        Button
        {
            id:btnCommunicateSettings
            Layout.row: 0
            Layout.column: 1
            Layout.preferredWidth : 185
            Layout.preferredHeight: 85
            background: Rectangle{
                border.width: 0
                color: "#7584C2"
                    }

            text: qsTr("通讯设置")
            font.pixelSize: 25
            palette.buttonText: "white"
            onClicked: {
                myLoader.setSource("EnterPwdPanel.qml", {"enterViewUrl":"CommunucationSettings.qml","lastViewUrl":"SettingsPanel.qml","passwordType":1})
            }
        }
        Button
        {
            id:btnMqttSettings
            Layout.row: 0
            Layout.column: 2
            Layout.preferredWidth : 185
            Layout.preferredHeight: 85
            background: Rectangle{
                border.width: 0
                color: "#7584C2"
                    }

            text: "MQTT"
            font.pixelSize: 25
            palette.buttonText: "white"
            onClicked: {
                myLoader.setSource("EnterPwdPanel.qml", {"enterViewUrl":"MQTTConfigPanel.qml","lastViewUrl":"SettingsPanel.qml","passwordType":1})
                //bottomBar.selected=4
                //myLoader.source="MQTTConfigPanel.qml"
            }
        }
        /*Button
        {
            id:btnAdvanceSettings
            Layout.row: 1
            Layout.column: 2
            Layout.preferredWidth : 185
            Layout.preferredHeight: 85
            background: Rectangle{
                border.width: 0
                color: "#7584C2"
                    }

            text: qsTr("高级设置")
            font.pixelSize: 25
            palette.buttonText: "white"
            onClicked: {

                //rectangle.selectedView=8
                bottomBar.selected=4
                myLoader.setsource="GeneralSettingsPanel.qml"
                //pwd
//                rectangle.selectedView =7
//                enterPwdPanel.lastViewIndex=4
//                enterPwdPanel.lastBottomButtonIndex=4

//                enterPwdPanel.enterViewIndex=8
//                enterPwdPanel.enterBottomButtonIndex=4
//                enterPwdPanel.lastView = settingsPanel
            }
        }*/
        /*Button
        {
            id:btnHoldMode
            Layout.row: 1
            Layout.column: 0
            Layout.preferredWidth : 185
            Layout.preferredHeight: 85
            background: Rectangle{
                border.width: 0
                color: "#7584C2"
                    }

            text: qsTr("保持模式")
            font.pixelSize: 25
            palette.buttonText: "white"
            onClicked: {

                //rectangle.selectedView=9
                //bottomBar.selected=4
myLoader.setsource="HoldModeSettings.qml"
//                pwd
//                rectangle.selectedView =7
//                enterPwdPanel.lastViewIndex=4
//                enterPwdPanel.lastBottomButtonIndex=4

//                enterPwdPanel.enterViewIndex=9
//                enterPwdPanel.enterBottomButtonIndex=4
//                enterPwdPanel.lastView = settingsPanel
            }
        }*/
        /*Button
        {
            id:btnPreSettings
            Layout.row: 1
            Layout.column: 1
            Layout.preferredWidth : 185
            Layout.preferredHeight: 85
            background: Rectangle{
                border.width: 0
                color: "#7584C2"
                    }

            text: qsTr("预置位设置")
            font.pixelSize: 25
            palette.buttonText: "white"
            onClicked: {

                //rectangle.selectedView=10
                bottomBar.selected = 4
                myLoader.setsource="PresetPositionSettingPanel.qml"

//                pwd
//                rectangle.selectedView =7
//                enterPwdPanel.lastViewIndex=4
//                enterPwdPanel.lastBottomButtonIndex=4

//                enterPwdPanel.enterViewIndex=10
//                enterPwdPanel.enterBottomButtonIndex=4
//                enterPwdPanel.lastView = settingsPanel
                    }
        }*/
        Button
        {
            id:btnLanguageDate
            Layout.row: 1
            Layout.column: 1/*
            Layout.columnSpan: 2
            anchors.horizontalCenter: parent.horizontalCenter*/
            Layout.preferredWidth : 185
            Layout.preferredHeight: 85
            background: Rectangle{
                border.width: 0
                color: "#7584C2"
                    }

            text: qsTr("日期")
            font.pixelSize: 25
            palette.buttonText: "white"
            onClicked: {
                        //rectangle.selectedView=11
                        bottomBar.selected=4
//                myLoader.visible=false;
//                myLoader.visible=true
                myLoader.source="DatePanel.qml"
                    }
        }

        Button
        {
            id:btnLanguageSettings
            Layout.row: 1
            Layout.column: 0
            Layout.preferredWidth : 185
            Layout.preferredHeight: 85
            background: Rectangle{
                border.width: 0
                color: "#7584C2"
                    }

            text: qsTr("语言")
            font.pixelSize: 25
            palette.buttonText: "white"
            onClicked: {
                //settingsLoader.visible=true;
                bottomBar.selected=4
//                myLoader.visible=false;
//                myLoader.visible=true
                myLoader.source="LanguagePanel.qml"
            }
        }
        MyBuzyIndicator{    //哦 按Layout.alignmen写，仍报错。
            //zeroCalibrationLayout.layer.alignment: Qt.AlignCenter
            Layout.alignment: Qt.AlignCenter
            //anchors.centerIn: parent    //哦哦 豆包说：被GridLayout布局管理器管理的控件，不能使用锚定anchors.xxx，因为会冲突。
            id: settingsLoader          //解决方法：将锚定属性替换为布局系统对应的属性，主要是Layout.alignment。
            visible:false

        }
    }
//    MyBuzyIndicator{  //哦哦 写在外面就好了。
//        //Layout.alignment: Qt.AlignCenter
//        anchors.centerIn: parent    //哦哦 豆包说：被GridLayout布局管理器管理的控件，不能使用锚定anchors.xxx，因为会冲突。
//        id: settingsLoader          //解决方法：将锚定属性替换为布局系统对应的属性，主要是Layout.alignment。
//        visible:false
//    }
  }

